//
//  ViewController.m
//  webIOS
//
//  Created by Canny on 2018/10/19.
//  Copyright © 2018年 WK. All rights reserved.
//

#import "ViewController.h"
#import "KKWebViewController.h"
#import "ExceptionView.h"

@interface ViewController ()<UITextFieldDelegate>

@property (nonatomic,strong)UITextField * textfeild;
@property(nonatomic, strong)ExceptionView * exceptionView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"选择地址";
    
    self.view.backgroundColor = RGB(255, 255, 255);
    
    UIButton * adress1 = [[UIButton alloc]init];
    adress1.frame=CGRectMake(10, 100, G_SCREENWIDTH-20, 50);
    adress1.backgroundColor = RGB(143, 221, 89);
    [adress1 setTitle:@"http://dev-h5.3iex.com" forState:UIControlStateNormal];
    [self.view addSubview:adress1];
    adress1.tag = 10001;
    [adress1 addTarget:self action:@selector(goToWeb:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton * adress2 = [[UIButton alloc]init];
    adress2.frame=CGRectMake(10, 200, G_SCREENWIDTH-20, 50);
    adress2.backgroundColor = RGB(255, 171, 181);
    [adress2 setTitle:@"http://192.168.3.8:8080" forState:UIControlStateNormal];
    [self.view addSubview:adress2];
    adress2.tag = 10002;
    [adress2 addTarget:self action:@selector(goToWeb:) forControlEvents:UIControlEventTouchUpInside];
    
    UITextField *textfeild = [[UITextField alloc] init];
    [self.view addSubview:textfeild];
    textfeild.text=@"http://";
    textfeild.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入地址" attributes:@{NSForegroundColorAttributeName : RGB(181, 181, 181),NSFontAttributeName : [UIFont systemFontOfSize:MC_REALVALUE(12)]}];
    textfeild.clearButtonMode = UITextFieldViewModeWhileEditing;
    textfeild.layer.cornerRadius = 5;
    textfeild.backgroundColor = RGB(237, 252, 255);
    textfeild.font = [UIFont systemFontOfSize:MC_REALVALUE(12)];
    textfeild.delegate = self;
    textfeild.autocorrectionType = UITextAutocorrectionTypeNo;
    textfeild.textColor = RGB(255, 210, 0);
    self.textfeild = textfeild;
    textfeild.frame = CGRectMake(10, 300, G_SCREENWIDTH-100, 50);
    UIButton * adress3 = [[UIButton alloc]init];
    adress3.frame= CGRectMake(10+ G_SCREENWIDTH-100+10, 300, 50, 50);
    adress3.backgroundColor = RGB(112, 112, 112);
    [self.view addSubview:adress3];
    [adress3 setTitle:@"Go" forState:UIControlStateNormal];
    adress3.tag = 10003;
    [adress3 addTarget:self action:@selector(goToWeb:) forControlEvents:UIControlEventTouchUpInside];
    
    
    
//    KKWebViewController * vc = [[KKWebViewController alloc]init];
//    vc.title=@"KK";
//    vc.url = @"https://www.baidu.com";
////    [self.navigationController pushViewController:vc animated:NO];
//
//    [MOLoadHttpsData PostHttpDataWithUrlStr:@"https://mbappzxurlxl2.zzxx9.com/web-api/api/v4/update_app" Dic:@{} SuccessBlock:^(id  _Nonnull responseObject) {
//
//    } FailureBlock:^(id  _Nonnull error) {
//
//    }];
//
//    [MOLoadHttpsData GetHttpDataWithUrlStr:@"http://v.juhe.cn/historyWeather/province" Dic:@{} SuccessBlock:^(id responseObject) {
//
//        /**
//         **  在这里 可以获取到成功返回的请求数据
//         **/
//
//    } FailureBlock:^(id error) {
//
//        /**
//         **  在这里 可以获取到失败返回的请求数据
//         **/
//    }];
    
    
}
-(void)goToWeb{
    
    if (_textfeild.text) {
        
    }
    KKWebViewController * vc = [[KKWebViewController alloc]init];
    vc.title = @"3iEX";
    
    [self.navigationController pushViewController:vc animated:YES];
    
}

-(void)goToWeb:(UIButton *)btn{
    
    KKWebViewController * vc = [[KKWebViewController alloc]init];
    vc.title = @"3iEX";
    if (btn.tag==10001) {
        vc.url = @"http://dev-h5.3iex.com";
    }else if (btn.tag==10002){
        vc.url = @"http://192.168.3.8:8080";
    }else if (btn.tag==10003){
        vc.url = _textfeild.text;
    }
    [self.navigationController pushViewController:vc animated:YES];
    
    
}

@end



























